package com.yupi.springbootinit.exception;

import java.util.concurrent.RejectedExecutionHandler;
import java.util.concurrent.ThreadPoolExecutor;

/**
 * @Author: LiangXinRui
 * @Date: 2023/07/31/12:24
 * @Description: 创建一个自定义的拒绝策略类 CustomRejectedExecutionHandler，它实现 RejectedExecutionHandler 接口：
 */
public class CustomRejectedExecutionHandler implements RejectedExecutionHandler {
    @Override
    public void rejectedExecution(Runnable runnable, ThreadPoolExecutor executor) {
        // 抛出自定义的 TaskRejectedException 异常
        throw new TaskRejectedException("任务被拒绝执行，线程池队列已满！");
    }
}

